class GraphQLQueryManager:
    @staticmethod
    def problemset_question_list(category_slug="", skip=0, limit=50, filters={}):
        return {
            "query": "\n    query problemsetQuestionList($categorySlug: String, $limit: Int, $skip: Int, $filters: QuestionListFilterInput) {\n  problemsetQuestionList(\n    categorySlug: $categorySlug\n    limit: $limit\n    skip: $skip\n    filters: $filters\n  ) {\n    hasMore\n    total\n    questions {\n      acRate\n      difficulty\n      freqBar\n      frontendQuestionId\n      isFavor\n      paidOnly\n      solutionNum\n      status\n      title\n      titleCn\n      titleSlug\n      topicTags {\n        name\n        nameTranslated\n        id\n        slug\n      }\n      extra {\n        hasVideoSolution\n        topCompanyTags {\n          imgUrl\n          slug\n          numSubscribed\n        }\n      }\n    }\n  }\n}\n    ",
            "variables": {
                "categorySlug": category_slug,
                "skip": skip,
                "limit": limit,
                "filters": filters
            },
            "operationName": "problemsetQuestionList"
        }

    @staticmethod
    def question_topics_list(question_slug, skip=15, first=15, order_by="DEFAULT", user_input="", tag_slugs=[]):
        return {
            "query": "\n    query questionTopicsList($questionSlug: String!, $skip: Int, $first: Int, $orderBy: SolutionArticleOrderBy, $userInput: String, $tagSlugs: [String!]) {\n  questionSolutionArticles(\n    questionSlug: $questionSlug\n    skip: $skip\n    first: $first\n    orderBy: $orderBy\n    userInput: $userInput\n    tagSlugs: $tagSlugs\n  ) {\n    totalNum\n    edges {\n      node {\n        ipRegion\n        rewardEnabled\n        canEditReward\n        uuid\n        title\n        slug\n        sunk\n        chargeType\n        status\n        identifier\n        canEdit\n        canSee\n        reactionType\n        hasVideo\n        favoriteCount\n        upvoteCount\n        reactionsV2 {\n          count\n          reactionType\n        }\n        tags {\n          name\n          nameTranslated\n          slug\n          tagType\n        }\n        createdAt\n        thumbnail\n        author {\n          username\n          profile {\n            userAvatar\n            userSlug\n            realName\n            reputation\n          }\n        }\n        summary\n        topic {\n          id\n          commentCount\n          viewCount\n          pinned\n        }\n        byLeetcode\n        isMyFavorite\n        isMostPopular\n        isEditorsPick\n        hitCount\n        videosInfo {\n          videoId\n          coverUrl\n          duration\n        }\n      }\n    }\n  }\n}\n    ",
            "variables": {
                "questionSlug": question_slug,
                "skip": skip,
                "first": first,
                "orderBy": order_by,
                "userInput": user_input,
                "tagSlugs": tag_slugs
            },
            "operationName": "questionTopicsList"
        }


    @staticmethod
    def get_study_plan_catalogs():
        return {
            "query": "\n    query GetStudyPlanCatalogs {\n  studyPlanV2Catalogs {\n    name\n    recommendedStudyPlans\n    slug\n  }\n}\n    ",
            "variables": {},
            "operationName": "GetStudyPlanCatalogs"
        }


    @staticmethod
    def get_study_plan_by_catalog(catalog_slug, offset=0, limit=12):
        return {
            "query": "\n    query GetStudyPlanByCatalog($catalogSlug: String!, $offset: Int!, $limit: Int!) {\n  studyPlansV2ByCatalog(catalogSlug: $catalogSlug, offset: $offset, limit: $limit) {\n    hasMore\n    total\n    studyPlans {\n      slug\n      questionNum\n      premiumOnly\n      onGoing\n      name\n      highlight\n      cover\n    }\n  }\n}\n    ",
            "variables": {
                "catalogSlug": catalog_slug,
                "offset": offset,
                "limit": limit
            },
            "operationName": "GetStudyPlanByCatalog"
        }


    @staticmethod
    def study_plan_detail(slug):
        return {
            "query": "\n    query studyPlanDetail($slug: String!) {\n  studyPlanV2Detail(planSlug: $slug) {\n    slug\n    name\n    highlight\n    staticCoverPicture\n    colorPalette\n    threeDimensionUrl\n    description\n    premiumOnly\n    needShowTags\n    awardDescription\n    defaultLanguage\n    award {\n      name\n      config {\n        icon\n        iconGif\n        iconGifBackground\n      }\n    }\n    relatedStudyPlans {\n      cover\n      highlight\n      name\n      slug\n      premiumOnly\n    }\n    planSubGroups {\n      slug\n      name\n      premiumOnly\n      questionNum\n      questions {\n        translatedTitle\n        titleSlug\n        title\n        questionFrontendId\n        paidOnly\n        id\n        difficulty\n        topicTags {\n          slug\n          nameTranslated\n          name\n        }\n        solutionInfo {\n          solutionSlug\n          solutionTopicId\n        }\n      }\n    }\n  }\n}\n    ",
            "variables": {
                "slug": slug
            },
            "operationName": "studyPlanDetail"
        }


    @staticmethod
    def question_company_tags_v2(offset=15):
        return {
            "query": "\n    query questionCompanyTagsV2($offset: Int) {\n  companyTagsV2(limit: 15, offset: $offset) {\n    companyTagInfoNodes {\n      name\n      slug\n      id\n      questionCount: companyQuestionNum\n    }\n    hasMore\n  }\n}\n    ",
            "variables": {
                "offset": offset
            },
            "operationName": "questionCompanyTagsV2"
        }

    @staticmethod
    def company_questions(slug):
        return {
            "query": "query companyQuestions($slug: String!) {\n  companyTag(slug: $slug) {\n    frequencies\n    questions {\n      questionId\n      frequencyTimePeriod\n      __typename\n    }\n    __typename\n  }\n}\n",
            "variables": {
                "slug": slug
            },
            "operationName": "companyQuestions"
        }

    @staticmethod
    def trending_contents(skip=0, limit=6, sub_list_slug="zhou-6"):
        return {
            "query": "query trendingContents($limit: Int!, $skip: Int!, $subListSlug: String!) {\n  trendingContents(limit: $limit, skip: $skip, subListSlug: $subListSlug) {\n    ... on TrendingQuestionNode {\n      companyTags {\n        slug\n        imgUrl\n        __typename\n      }\n      companyTagCount\n      otherTags {\n        name\n        nameTranslated\n        slug\n        __typename\n      }\n      otherTagCount\n      difficulty\n      translatedTitle\n      title\n      titleSlug\n      __typename\n    }\n    ... on TrendingQAOrArticleNode {\n      author {\n        name\n        userSlug\n        avatar\n        __typename\n      }\n      uuid\n      summary\n      title\n      createdAt\n      articleType\n      __typename\n    }\n    ... on TrendingSolutionNode {\n      videoCoverUrl\n      author {\n        name\n        userSlug\n        __typename\n      }\n      questionSlug\n      questionTitle\n      translatedQuestionTitle\n      title\n      slug\n      createdAt\n      __typename\n    }\n    ... on TrendingTagNode {\n      name\n      nameTranslated\n      slug\n      tagType\n      __typename\n    }\n    __typename\n  }\n}\n",
            "variables": {
                "skip": skip,
                "limit": limit,
                "subListSlug": sub_list_slug
            },
            "operationName": "trendingContents"
        }

    @staticmethod
    def question_tag_type_with_tags():
        return {
            "query": "\n    query questionTagTypeWithTags {\n  questionTagTypeWithTags {\n    name\n    transName\n    tagRelation {\n      questionNum\n      tag {\n        name\n        id\n        nameTranslated\n        slug\n      }\n    }\n  }\n}\n    ",
            "variables": {},
            "operationName": "questionTagTypeWithTags"
        }

    @staticmethod
    def plan_groups_by_tag(tag_slug):
        return {
            "query": "query planGroupsByTag($tagSlug: String!) {\n  planGroupsByTag(tagSlug: $tagSlug, limit: 100, skip: 0) {\n    data {\n      cover\n      name\n      slug\n      dailyQuestionNum\n      days\n      plans {\n        name\n        slug\n        awarded\n        medal {\n          config {\n            icon\n            iconGif\n            iconGifBackground\n            iconWearing\n            __typename\n          }\n          name\n          __typename\n        }\n        __typename\n      }\n      ongoingProgress {\n        startedAt\n        endAt\n        completedNum\n        id\n        questionNum\n        __typename\n      }\n      __typename\n    }\n    __typename\n  }\n}\n",
            "variables": {
                "tagSlug": tag_slug
            },
            "operationName": "planGroupsByTag"
        }

    @staticmethod
    def get_tag(slug):
        return {
            "query": "query getTag($slug: String!) {\n  wikiEntry(slug: $slug) {\n    tag {\n      name\n      slug\n      nameTranslated\n      imgUrl\n      tagType\n      __typename\n    }\n    content\n    isPublic\n    __typename\n  }\n}\n",
            "variables": {
                "slug": slug
            },
            "operationName": "getTag"
        }

    @staticmethod
    def question_title(title_slug):
        return {
            "query": z,
            "variables": {
                "titleSlug": title_slug
            },
            "operationName": "questionTitle"
        }

    @staticmethod
    def question_content(title_slug):
        return {
            "query": "\n    query questionContent($titleSlug: String!) {\n  question(titleSlug: $titleSlug) {\n    content\n    editorType\n    mysqlSchemas\n    dataSchemas\n  }\n}\n    ",
            "variables": {
                "titleSlug": title_slug
            },
            "operationName": "questionContent"
        }

    @staticmethod
    def question_translations(title_slug):
        return {
            "query": "\n    query questionTranslations($titleSlug: String!) {\n  question(titleSlug: $titleSlug) {\n    translatedTitle\n    translatedContent\n  }\n}\n    ",
            "variables": {
                "titleSlug": title_slug
            },
            "operationName": "questionTranslations"
        }

    @staticmethod
    def premium_question(title_slug):
        return {
            "query": "\n    query premiumQuestion($titleSlug: String!) {\n  question(titleSlug: $titleSlug) {\n    isPaidOnly\n  }\n}\n    ",
            "variables": {
                "titleSlug": title_slug
            },
            "operationName": "premiumQuestion"
        }

    @staticmethod
    def question_editor_data(title_slug):
        return {
            "query": "\n    query questionEditorData($titleSlug: String!) {\n  question(titleSlug: $titleSlug) {\n    questionId\n    questionFrontendId\n    codeSnippets {\n      lang\n      langSlug\n      code\n    }\n    envInfo\n    enableRunCode\n    hasFrontendPreview\n    frontendPreviews\n  }\n}\n    ",
            "variables": {
                "titleSlug": title_slug
            },
            "operationName": "questionEditorData"
        }

    @staticmethod
    def question_hints(title_slug):
        return {
            "query": "\n    query questionHints($titleSlug: String!) {\n  question(titleSlug: $titleSlug) {\n    hints\n  }\n}\n    ",
            "variables": {
                "titleSlug": title_slug
            },
            "operationName": "questionHints"
        }

    @staticmethod
    def single_question_topic_tags(title_slug):
        return {
            "query": "\n    query singleQuestionTopicTags($titleSlug: String!) {\n  question(titleSlug: $titleSlug) {\n    topicTags {\n      name\n      slug\n      translatedName\n    }\n  }\n}\n    ",
            "variables": {
                "titleSlug": title_slug
            },
            "operationName": "singleQuestionTopicTags"
        }

    @staticmethod
    def similar_question(title_slug):
        return {
            "query": "\n    query similarQuestion($titleSlug: String!) {\n  question(titleSlug: $titleSlug) {\n    similarQuestions\n  }\n}\n    ",
            "variables": {
                "titleSlug": title_slug
            },
            "operationName": "similarQuestion"
        }

    @staticmethod
    def user_question_status(title_slug):
        return {
            "query": "\n    query userQuestionStatus($titleSlug: String!) {\n  question(titleSlug: $titleSlug) {\n    status\n  }\n}\n    ",
            "variables": {
                "titleSlug": title_slug
            },
            "operationName": "userQuestionStatus"
        }

    @staticmethod
    def question_solution_official_article(question_slug):
        return {
            "query": "\n    query questionSolutionOfficialArticle($questionSlug: String!) {\n  questionSolutionOfficialArticle(questionSlug: $questionSlug) {\n    solutionSlug\n    solutionTopicId\n  }\n}\n    ",
            "variables": {
                "questionSlug": question_slug
            },
            "operationName": "questionSolutionOfficialArticle"
        }

    @staticmethod
    def discuss_topic(slug):
        return {
            "query": "\n    query discussTopic($slug: String) {\n  solutionArticle(slug: $slug, orderBy: DEFAULT) {\n    ...solutionArticle\n    content\n    next {\n      slug\n      title\n    }\n    prev {\n      slug\n      title\n    }\n  }\n}\n    \n    fragment solutionArticle on SolutionArticleNode {\n  ipRegion\n  rewardEnabled\n  canEditReward\n  uuid\n  title\n  slug\n  sunk\n  chargeType\n  status\n  identifier\n  canEdit\n  canSee\n  reactionType\n  reactionsV2 {\n    count\n    reactionType\n  }\n  tags {\n    name\n    nameTranslated\n    slug\n    tagType\n  }\n  createdAt\n  thumbnail\n  author {\n    username\n    isDiscussAdmin\n    isDiscussStaff\n    profile {\n      userAvatar\n      userSlug\n      realName\n      reputation\n    }\n  }\n  summary\n  topic {\n    id\n    subscribed\n    commentCount\n    viewCount\n    post {\n      id\n      status\n      voteStatus\n      isOwnPost\n    }\n  }\n  byLeetcode\n  isMyFavorite\n  isMostPopular\n  favoriteCount\n  isEditorsPick\n  hitCount\n  videosInfo {\n    videoId\n    coverUrl\n    duration\n  }\n}\n    ",
            "variables": {
                "slug": slug
            },
            "operationName": "discussTopic"
        }

    @staticmethod
    def submit(question_id, typed_code, lang="python3", study_plan_slug=""):
        return {
                "lang": lang,
                "question_id": question_id,
                "typed_code": typed_code,
                "study_plan_slug": study_plan_slug
        }

    @staticmethod
    def submission_list(question_slug, offset=0, limit=20, last_key=None, lang=None, status=None):
        return {
            "query": "\n    query submissionList($offset: Int!, $limit: Int!, $lastKey: String, $questionSlug: String!, $lang: String, $status: SubmissionStatusEnum) {\n  submissionList(\n    offset: $offset\n    limit: $limit\n    lastKey: $lastKey\n    questionSlug: $questionSlug\n    lang: $lang\n    status: $status\n  ) {\n    lastKey\n    hasNext\n    submissions {\n      id\n      title\n      status\n      statusDisplay\n      lang\n      langName: langVerboseName\n      runtime\n      timestamp\n      url\n      isPending\n      memory\n      submissionComment {\n        comment\n        flagType\n      }\n    }\n  }\n}\n    ",
            "variables": {
                "questionSlug": question_slug,
                "offset": offset,
                "limit": limit,
                "lastKey": last_key,
                "lang": lang,
                "status": status
            },
            "operationName": "submissionList"
        }

    @staticmethod
    def distributed_submission(input={
        "titleSlug": "two-sum",
        "distributionType": "RUNTIME",
        "lang": "python3",
        "nextId": "",
        "observerId": "437361902",
        "value": 1181,
        "maxValue": 1211,
        "minValue": 1152
    }):
        return {
            "query": "\n    query distributedSubmission($input: DistributedSubmissionInput!) {\n  distributedSubmission(in: $input) {\n    hasMore\n    nextId\n    submission {\n      id\n      code\n      runtime\n      memory\n      date\n      user {\n        realName\n        userSlug\n        userAvatar\n      }\n    }\n  }\n}\n    ",
            "variables": {
                "input": input
            },
            "operationName": "distributedSubmission"
        }

{
    "query": "\n    query languageList {\n  languageList {\n    id\n    name\n  }\n}\n    ",
    "variables": {},
    "operationName": "languageList"
}

{
    "query": "\n    query consolePanelConfig($titleSlug: String!) {\n  question(titleSlug: $titleSlug) {\n    questionId\n    questionFrontendId\n    questionTitle\n    enableRunCode\n    enableSubmit\n    enableTestMode\n    jsonExampleTestcases\n    exampleTestcases\n    metaData\n    sampleTestCase\n  }\n}\n    ",
    "variables": {
        "titleSlug": "two-sum"
    },
    "operationName": "consolePanelConfig"
}

{
    "query": "\n    query submissionFilterTypes {\n  languageList {\n    id\n    verboseName\n  }\n  statusList {\n    id\n    name: translatedName\n  }\n}\n    ",
    "variables": {},
    "operationName": "submissionFilterTypes"
}
# https://leetcode.cn/submissions/api/memory_distribution/481993149/
{
    "memory_distribution_formatted": "{\"lang\": \"python3\", \"distribution\": [[\"0\", 0.136], [\"16584\", 0.0022], [\"16592\", 0.0022], [\"16596\", 0.0022], [\"16632\", 0.0044], [\"16640\", 0.0022], [\"16664\", 0.0022], [\"16668\", 0.0022], [\"16672\", 0.011], [\"16680\", 0.0044], [\"16684\", 0.0066], [\"16692\", 0.0022]]}",
    "enable_memory_distribution": true,
    "should_show_result": true,
    "merged_distribution": [
        {
            "displayed_value": 112,
            "min_value": 0,
            "max_value": 225,
            "percent": 0.136
        },
        {
            "displayed_value": 337,
            "min_value": 225,
            "max_value": 450,
            "percent": 0
        },
    ],
    "lang_display": "python3"
}

# https://leetcode.cn/submissions/api/runtime_distribution/481993149/
{
    "runtime_distribution_formatted": "{\"lang\": \"python3\", \"distribution\": [[\"20\", 0.0153], [\"24\", 0.0921], [\"28\", 0.5], [\"32\", 1.7674], [\"36\", 4.2781], [\"40\", 8.7054], [\"44\", 11.2666], [\"48\", 9.918], [\"52\", 5.2495]]}",
    "should_show_result": true,
    "merged_distribution": [
        {
            "displayed_value": 50,
            "min_value": 20,
            "max_value": 80,
            "percent": 47.0487
        },
        {
            "displayed_value": 110,
            "min_value": 80,
            "max_value": 140,
            "percent": 0.2501
        },
    ],
    "lang_display": "python3"
}
# https://leetcode.cn/graphql/noj-go/
{
    "query": "\n    query distributedSubmission($input: DistributedSubmissionInput!) {\n  distributedSubmission(in: $input) {\n    hasMore\n    nextId\n    submission {\n      id\n      code\n      runtime\n      memory\n      date\n      user {\n        realName\n        userSlug\n        userAvatar\n      }\n    }\n  }\n}\n    ",
    "variables": {
        "input": {
            "titleSlug": "two-sum",
            "distributionType": "MEMORY",
            "lang": "python3",
            "nextId": "",
            "observerId": "481993149",
            "value": 112,
            "maxValue": 225,
            "minValue": 0
        }
    },
    "operationName": "distributedSubmission"
}




{
    "data": {
        "submissionList": {
            "lastKey": "r3dafn7xg",
            "hasNext": false,
            "submissions": [
                {
                    "id": "481993149",
                    "title": "两数之和",
                    "status": "AC",
                    "statusDisplay": "Accepted",
                    "lang": "python3",
                    "langName": "Python3",
                    "runtime": "380 ms",
                    "timestamp": "1699931049",
                    "url": "/submissions/detail/481993149/",
                    "isPending": "Not Pending",
                    "memory": "16.6 MB",
                    "submissionComment": null
                },
            ]
        }
    }
}
# https://leetcode.cn/graphql/noj-go/
{
    "query": "\n    query syncedCode($questionSlug: String!, $langSlug: String!) {\n  problemsetUserSyncedCode(titleSlug: $questionSlug, lang: $langSlug) {\n    code\n    timestamp\n  }\n}\n    ",
    "variables": {
        "questionSlug": "sort-integers-by-the-power-value",
        "langSlug": "python3"
    },
    "operationName": "syncedCode"
}
{
    "data": {
        "problemsetUserSyncedCode": {
            "code": "class Solution:\n    def getKth(self, lo: int, hi: int, k: int) -> int:\n        def deep(num):\n            if num in d:\n                return d[num]\n            \n            \n            if num & 1 == 0:\n                d[num] = 1 + deep(num >> 1)\n            else:\n                d[num] = 1 + deep(3 * num + 1)\n            return d[num]\n        \n        d = {}\n        d[1] = 0\n        arr = []\n        for number in range(lo, hi+1):\n            arr.append((deep(number), number))\n        arr.sort()\n        return arr[k-1][1]",
            "timestamp": "2023-11-23T03:50:55.859Z"
        }
    }
}